package rest

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

var chReloadConfig chan string

func Start(chReload chan string) {

	chReloadConfig = chReload

	router := gin.Default()
	router.GET("/ok", ok)
	router.POST("/config/reload", configReload)
	_ = router.Run(":3000")
}

func ok(c *gin.Context) {
	c.String(http.StatusOK, "OK")
}

func configReload(c *gin.Context) {
	c.String(http.StatusOK, "OK")
	chReloadConfig <- "reload"
}